﻿using System;
using System.Collections.Generic;

namespace TextBasedRpg
{
    public class Command
    {
        public delegate void CommandDelegate(params string[] args);

        public static Dictionary<string, CommandDelegate> Menu = new Dictionary<string,CommandDelegate>();
        public static Dictionary<string, string> HelpDict = new Dictionary<string, string>
        {
            {"help", "\nA command where you can see all non-hidden commands \nYou can also get info about a certain command\nSyntax - \"help\" \"help commandName\""},
            {"quit", "A depressing command that allows you to quit the game.\nIf you must use this, we hope you still had fun!\nSyntax - \"quit\""},
            {"roll", "\nA command that allows you to roll for a Psuedo-Random number\nSyntax - \"roll minNum maxNum\" \"roll 0 12\""}
        };

        public static void Help(params string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Help -- Opens this help text");
                Console.WriteLine("Play -- Starts the game");
                Console.WriteLine("Quit -- Exits the game");
                Console.WriteLine("Roll -- Roll for a number between two numbers");
            }
            else
                try
                {
                    string s = args[0].ToLower();
                    Console.WriteLine(HelpDict[s]);
                }
                catch { Console.WriteLine("That command cannot be found"); }
        }

        public static void Quit(params string[] args)
        {
            Console.WriteLine("See ya real soon!");
            Program.IsRunning = false;
        }

        public static void Play(params string[] args)
        {
            Console.WriteLine("Please pardon our dust. We are renovating this area for your future enjoyment.");
        }

        public static void Roll(params string[] args)
        {
            int min = Convert.ToInt32(args[0]);
            int max = Convert.ToInt32(args[1]);
            Random rand = new Random();
            Console.WriteLine(rand.Next(min, max));
        }

        #region Setup Dictionary Methods
        public static void setupBasic()
        {
            Menu = new Dictionary<string, CommandDelegate>{
                    {"help", Help},
                    {"quit", Quit},
                    {"h", Help},
                    {"q", Quit},
                    {"roll", Roll}
            };
        }

        public static void setupMenu()
        {
            Menu.Clear();

            setupBasic();
            Menu.Add("play", Play);
            Menu.Add("p", Play);
        }
        #endregion
    }
}
